﻿using FastEventBus.Application;
using FastEventBus.Realization;
using FastUtil.Config;
using FastUtil.Data;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text;

namespace FastCore.Test.Event
{
    [TestClass]
    public class EventOperate
    {
        [TestMethod]
        public void CommonOperate()
        {
            MailEventHandler handle = new MailEventHandler();
            EventBus.GetInstance().Subscribe(handle);
            Dictionary<string, object> Params = new Dictionary<string, object>();
            Params.Add("Mail", "yanpeng19940119@gmail.com");
            EventBus.GetInstance().Publish("Mail", Params);
        }

        [TestMethod]
        public void RedisEvent()
        {
            RedisUtil.SetRedisConnectionString(AppConfigUtil.Configuration["ConnectionStrings:Redis_ConnectionString"]);
            EventBus.GetInstance().SetEventStroage(new RedisEventStroage());

            MailEventHandler handle = new MailEventHandler();
            EventBus.GetInstance().Subscribe(handle);
            Dictionary<string, object> Params = new Dictionary<string, object>();
            Params.Add("Mail", "yanpeng19940119@gmail.com");
            EventBus.GetInstance().Publish("Mail", Params);
        }
    }
}
